package com.example.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    override fun onRestart() {
        super.onRestart()
        Log.i("szjonRestartMain", "onCreate")
    }


    fun onDialogClick(view: View) {
        val view = LayoutInflater.from(this).inflate(R.layout.dialog_item, null, false)

        val dialog = SwitchDialogFragment(view, "提醒", this)

        dialog.show(supportFragmentManager, dialog.tag)


        //RootView 宽高
        dialog.setRootViewLayoutParams(ViewGroup.MarginLayoutParams.MATCH_PARENT, 300)

        //左侧/右侧名字
        dialog.setLeftName("NO")
        dialog.setRightName("YES")

//        //左侧按钮隐藏
        dialog.setLeftVisibility(true)

        //点击外部是否消失
        dialog.setDisappear(true)

        //底部弹出
        dialog.setBottomShow(true)

        //显示动画
        dialog.setDialogAnimation(true)

        //按钮点击事件回调
        dialog.setOnDialogClick(object : SwitchDialogFragment.onDialogClick {
            //右侧按钮
            override fun onSuccess() {
                Toast.makeText(this@MainActivity, "右侧按钮", Toast.LENGTH_SHORT).show()
            }

            //左侧按钮
            override fun onClone() {
                Toast.makeText(this@MainActivity, "左侧按钮", Toast.LENGTH_SHORT).show()
            }
        })
    }
}